package com.niodata.dp.core.context;

import com.niodata.dp.core.usermgr.enums.SystemRole;
import com.niodata.dp.core.usermgr.model.UserInfo;
import java.sql.Timestamp;

public class NullContext implements Context {

  private static final NullContext instance;

  static {
    UserInfo fakedUser = new UserInfo();
    fakedUser.setCreateTime(new Timestamp(System.currentTimeMillis()));
    fakedUser.setDetail("detail");
    fakedUser.setEmail("email");
    fakedUser.setLoginName("faked");
    fakedUser.setPassword("12345");
    fakedUser.setRole(SystemRole.USER);
    fakedUser.setUserId(12345L);
    fakedUser.setUserName("user");
    instance = new NullContext(fakedUser);
  }

  private final UserInfo fakedUser;

  public NullContext(UserInfo faked) {
    this.fakedUser = faked;
  }

  static NullContext instance() {
    return instance;
  }

  @Override
  public UserInfo currentUser() {
    return fakedUser;
  }

}
